/**
 * WebSocketHandler.js
 * @author Ulyan Sobin
 * @description WebSocketHandler class
 */

"use strict";

const { WebHandler } = require("../WebHandler");
const { WebSocketClient } = require("./WebSocketClient");

/**
 * @callback ResolveFunction
 * @param { WebSocketClient } client
 */

class WebSocketHandler extends WebHandler {

	/** @type { ResolveFunction } */
	resolve;

	/**
	 * Constructor of `WebSocketHandler`
	 * @param {ResolveFunction} resolve 
	 */
	constructor (resolve) {
		super();
		this.resolve = resolve;
	}

	/**
	 * 
	 * @param { WebClient } client 
	 */
	route(client) {
		this.resolve(client);
	}
}

module.exports.WebSocketHandler = WebSocketHandler;